home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr49
/
actlib11.zip
/
DATE.ZIP
/
DIFFDATE.C
< prev
next >
Wrap
Text File
|
1993-01-14
|
984b
|
40 lines
/* Copyright (C) 1993 Marc Stern (internet: stern@mble.philips.be) */
#include "date.h"
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#include <dos.h>
/***
*
* Function diffdate : Compare two dates
* Return date1 - date2
*
* Return : Number of days between date1 and date2
*
* Decisions : No validity checks are made on dates;
* if dates are not valid, result is unpredictable.
*
***/
long diffdate( struct tm dtime1 , struct tm dtime2 )
{ long delay ;
int year ;
mktime( &dtime1 ) ; mktime( &dtime2 ) ;
delay = 365L * ( dtime1.tm_year - dtime2.tm_year ) + ( dtime1.tm_yday - dtime2.tm_yday ) ;
for ( year = dtime1.tm_year ; year < dtime2.tm_year; year ++ )
if ( isleapyear(dtime1.tm_year) ) delay -- ;
for ( year = dtime2.tm_year ; year < dtime1.tm_year; year ++ )
if ( isleapyear(dtime2.tm_year) ) delay ++ ;
return delay ;
}